package org.common4j2ee.s2shs.web.utils;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextImpl;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial") 
public abstract class BaseAction extends ActionSupport  {

	protected Logger logger = LoggerFactory.getLogger(getClass());

	protected String getUserName() {
		Object content=Struts2Utils
		.getSession().getAttribute("SPRING_SECURITY_CONTEXT");
		if(content==null){
			return null;
		}
		SecurityContextImpl securityContent = (SecurityContextImpl) content;
		Authentication auth=securityContent.getAuthentication();
		if(auth==null){
			return null;
		}
		return auth.getName();
	}
}
